package com.huawei.gamebox.service.welfare.gift.node;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.huawei.gamebox.service.common.cardkit.card.BaseGsCard;
import com.huawei.gamebox.service.common.cardkit.node.BaseGsNode;
import com.huawei.gamebox.service.welfare.gift.card.BaseGiftCard;
import o.azb;
import o.ccz;
import o.chy;
import o.exp$a;
import o.exp$c;
import o.exp$e;
import o.exp$f;
import o.exp.d;
import o.exp.j;

public class BaseGiftNode extends BaseGsNode {
    protected LayoutInflater ˊ;

    public BaseGiftNode(Context context) {
        super(context);
        this.ˊ = LayoutInflater.from(context);
    }

    protected View ˊ(LayoutInflater layoutInflater) {
        return null;
    }

    protected View ॱ(LayoutInflater layoutInflater) {
        if (layoutInflater == null) {
            return null;
        }
        int i = j.ˊˊ;
        if (ˋ()) {
            i = j.ʼ;
        }
        View inflate = layoutInflater.inflate(i, null);
        if (!ˋ()) {
            azb.ˏ(inflate, d.ˎ);
        }
        TextView textView = (TextView) inflate.findViewById(d.ᶥ);
        textView.setText(this.ॱ.getText(exp$f.ᐝॱ));
        if (ˋ()) {
            ((TextView) inflate.findViewById(d.ꜞ)).setTextColor(this.ॱ.getResources().getColor(exp$c.ʽ));
            textView.setTextColor(this.ॱ.getResources().getColor(exp$c.ˋ));
            ((ImageView) inflate.findViewById(d.ㆍ)).setImageResource(exp$e.ॱˊ);
        }
        return inflate;
    }

    int ˎ() {
        if (ˋ()) {
            return this.ॱ.getResources().getDimensionPixelSize(exp$a.ᐝ);
        }
        return azb.ˊ(this.ॱ);
    }

    void ॱ(BaseGiftCard baseGiftCard, int i, int i2) {
        LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
        layoutParams.weight = 1.0f;
        LinearLayout linearLayout = null;
        int i3 = 0;
        boolean z = false;
        while (i3 < i) {
            if (linearLayout == null || i3 % i2 == 0) {
                linearLayout = new LinearLayout(this.ॱ);
                linearLayout.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
                linearLayout.setOrientation(0);
                View ˉ = baseGiftCard.ˉ();
                if (ˉ instanceof ViewGroup) {
                    ((ViewGroup) ˉ).addView(linearLayout, layoutParams);
                }
                z = i - (i3 + 1) < i2;
            }
            View ˊ = ˊ(this.ˊ);
            if (ˊ != null) {
                BaseGsCard ˏ = ˏ(z);
                if (ˏ != null) {
                    ˏ.ˊ(i3 < i2);
                    ˏ.ˏ(ˊ);
                    baseGiftCard.ˋ(ˏ);
                    LayoutParams layoutParams2 = new LinearLayout.LayoutParams(-1, -1);
                    layoutParams2.weight = 1.0f;
                    linearLayout.addView(ˊ, layoutParams2);
                    if (i3 == i - 1 && i3 % i2 == 0) {
                        linearLayout.addView(new View(this.ॱ), layoutParams2);
                    }
                }
                i3++;
            } else {
                return;
            }
        }
        if (ᐝ() != null) {
            ˋ(ᐝ());
        }
    }

    void ˊ(BaseGiftCard baseGiftCard, int i) {
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
        layoutParams.weight = 1.0f;
        int i2 = 0;
        while (i2 < i) {
            View ˊ = ˊ(this.ˊ);
            if (ˊ != null) {
                BaseGsCard ˏ;
                boolean z;
                if (i2 == i - 1) {
                    ˏ = ˏ(true);
                } else {
                    ˏ = ˏ(false);
                }
                if (i2 == 0) {
                    z = true;
                } else {
                    z = false;
                }
                ˏ.ˊ(z);
                ˏ.ˏ(ˊ);
                baseGiftCard.ˋ(ˏ);
                ˋ(baseGiftCard, i, layoutParams, i2, ˊ);
                i2++;
            } else {
                return;
            }
        }
        ˋ(ᐝ());
    }

    private void ˋ(BaseGiftCard baseGiftCard, int i, LinearLayout.LayoutParams layoutParams, int i2, View view) {
        View ˉ = baseGiftCard.ˉ();
        if (ˉ instanceof ViewGroup) {
            ((ViewGroup) ˉ).addView(view, layoutParams);
        }
        if (i2 == i - 1 && view.findViewById(d.ˋˋ) != null) {
            view.findViewById(d.ˋˋ).setVisibility(8);
        }
    }

    protected chy ᐝ() {
        return null;
    }

    protected BaseGiftCard ˏ(boolean z) {
        return null;
    }

    protected int ʻ() {
        return ccz.ॱ();
    }
}
